package com.shiloop.sensorsampler;

import android.hardware.Sensor;

import java.util.ArrayList;

/**
 * Created by Baofeng on 2015/1/6.
 */
public class SensorWrapper {
    public static final int ACCELEROMETER = Sensor.TYPE_ACCELEROMETER;
    public static final int GRAVITY = Sensor.TYPE_GRAVITY;
    public static final int MAGNETIC = Sensor.TYPE_MAGNETIC_FIELD;
    public static final int GYROSCOPE = Sensor.TYPE_GYROSCOPE;
    public static final int ROTATION = Sensor.TYPE_ROTATION_VECTOR;

    public static ArrayList<Integer> getTypeArray() {
        ArrayList<Integer> integers = new ArrayList<Integer>(4);
        integers.add(ACCELEROMETER);
        integers.add(GRAVITY);
        integers.add(MAGNETIC);
        integers.add(GYROSCOPE);
        integers.add(ROTATION);
        return integers;
    }

    public static ArrayList<SensorWrapper> getWrapperArray() {
        ArrayList<SensorWrapper> wrappers = new ArrayList<SensorWrapper>(4);
        wrappers.add(new SensorWrapper(ACCELEROMETER));
        wrappers.add(new SensorWrapper(GRAVITY));
        wrappers.add(new SensorWrapper(MAGNETIC));
        wrappers.add(new SensorWrapper(GYROSCOPE));
        wrappers.add(new SensorWrapper(ROTATION));
        return wrappers;
    }

    private int mType;

    @Override
    public String toString() {
        switch (mType) {
            case ACCELEROMETER:
                return "加速度传感器";
            case GRAVITY:
                return "重力加速度";
            case MAGNETIC:
                return "磁场感应器";
            case GYROSCOPE:
                return "陀螺仪";
            case ROTATION:
                return "方向传感器";
            default:
                return "其他传感器";
        }
    }

    public SensorWrapper(int type) {
        mType = type;
    }

    public int getType() {
        return mType;
    }
}
